<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>发布车辆信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="assets/layui/css/layui.css">
	<link rel="stylesheet" href="assets/css/all.css" />
	<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
	<!--[if lt IE 9]>
	  <script src="assets/js/html5shiv.js"></script>
	  <script src="assets/js/respond.min.js"></script>
	<![endif]-->
</head>
<body class="edit-car-infor">
	<div class="layui-fluid">
		<div class="layui-text">
			<h2 class="layui-field-title" style="text-align: center;">请详细填写以下内容</h2>
			<p class="warm-tip">注：带*为必填项</p>
		</div>
		<form class="layui-form" action="" onsubmit="return false">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label  "><span class="musthave">*</span>车辆编号</label>
					<div class="layui-input-inline">
						<input type="text" name="number" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  "><span class="musthave">*</span>车辆归属</label>
					<div class="layui-input-inline">
						<select name="carbelong" lay-verify="required">
					        <option value="">请选择</option>
					        <option value="1">个人</option>
					        <option value="2">单位</option>
				        </select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  "><span class="musthave">*</span>车型</label>
					<div class="layui-input-inline">
						<input type="text" name="carsee" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  "><span class="musthave">*</span>车牌</label>
					<div class="layui-input-inline">
						<input type="text" name="carnum" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  "><span class="musthave">*</span>车辆户籍地</label>
					<div class="layui-input-inline">
						<input type="text" name="caraddress" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  ">车架号（vin码）</label>
					<div class="layui-input-inline">
						<input type="text" name="vinnum" lay-verify="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  ">发动机号</label>
					<div class="layui-input-inline">
						<input type="text" name="enginenum" lay-verify="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  "><span class="musthave">*</span>事故类型</label>
					<div class="layui-input-inline">
						<select name="shigu" lay-verify="required">
					        <option value="">请选择</option>
					        <option value="1">事故车</option>
					        <option value="2">水淹车</option>
					        <option value="3">火烧车</option>
				        </select>
					</div>
				</div>				
				<div class="layui-inline">
					<label class="layui-form-label"><span class="musthave">*</span>登记日期</label>
					<div class="layui-input-inline">
						<input type="text" name="date" id="date" lay-verify="required" placeholder="年-月-日 时:分:秒" autocomplete="off" class="layui-input layui-date">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label"><span class="musthave">*</span>出险日期</label>
					<div class="layui-input-inline">
						<input type="text" name="date1" id="date1" lay-verify="required" placeholder="年-月-日 时:分:秒" autocomplete="off" class="layui-input layui-date">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  ">车辆性质</label>
					<div class="layui-input-inline">
						<select name="carnature">
					        <option value="">请选择</option>
					        <option value="1">运营车</option>
					        <option value="2">非运营车</option>
				        </select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  ">车辆类型</label>
					<div class="layui-input-inline">
						<select name="cartype">
					        <option value="">请选择</option>
					        <option value="1">轿车</option>
					        <option value="2">货车</option>
					        <option value="3">特种车</option>
				        </select>
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  ">承保金额</label>
					<div class="layui-input-inline">
						<input type="text" name="bxnum" lay-verify="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  ">估损金额</label>
					<div class="layui-input-inline">
						<input type="text" name="gsnum" lay-verify="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  ">全损金额</label>
					<div class="layui-input-inline">
						<input type="text" name="allnum" lay-verify='' autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label">发证日期</label>
					<div class="layui-input-inline">
						<input type="text" name="date2" id="date2" placeholder="年-月-日 时:分:秒" autocomplete="off" class="layui-input layui-date">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  ">品牌型号</label>
					<div class="layui-input-inline">
						<input type="text" name="brandtype" lay-verify="" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  ">所属分公司</label>
					<div class="layui-input-inline">
						<input id="department" type="text" name="fcompany" lay-verify="" autocomplete="off" class="layui-input">
					</div>
				</div>	
				<div class="layui-inline">
					<label class="layui-form-label  ">所属保险公司</label>
					<div class="layui-input-inline">
						<input id="department" type="text" name="fcompany" lay-verify="" autocomplete="off" class="layui-input">
					</div>
				</div>	
				<div class="layui-inline">
					<label class="layui-form-label  "><span class="musthave">*</span>定损员 </label>
					<div class="layui-input-inline">
						<input type="text" name="contacter" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-inline">
					<label class="layui-form-label  "><span class="musthave">*</span>联系电话</label>
					<div class="layui-input-inline">
						<input type="text" name="conphone" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>					
				<div class="layui-inline">
					<label class="layui-form-label"><span class="musthave">*</span>竞价结束日期</label>
					<div class="layui-input-inline">
						<input type="text" name="date4" id="date4" lay-verify="required" placeholder="年-月-日 时:分:秒" autocomplete="off" class="layui-input layui-date">
					</div>
				</div>	
				<div class="layui-form-item">
					<label class="layui-form-label">出险经过</label>
					<div class="layui-input-inline">
						<textarea name="cxjg" style="width:590px" placeholder="请输入内容" class="layui-textarea"></textarea>
					</div>
				</div>
				<div class="car-location">
					<div class="layui-form-item">
						<label class="layui-form-label">车辆停放地</label>
						<div class="layui-input-inline">
							<select name="provid" id="provid" lay-filter="provid">
								<option value="">请选择省</option>
							</select>
						</div>
						<div class="layui-input-inline">
							<select name="cityid" id="cityid" lay-filter="cityid">
								<option value="">请选择市</option>
							</select>
						</div>
						<div class="layui-input-inline">
							<select name="areaid" id="areaid" lay-filter="areaid" onchange="getlocation()">
								<option value="">请选择县/区</option>
							</select>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label"></label>
							<div class="layui-input-inline">
								<input id="detail-location" style="width:590px" type="text" name="detailid" placeholder="详细地址" autocomplete="off" class="layui-input" value="">
								<div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto; display:none;"></div>
							</div>
						</div>
					</div>
				</div>								
				<div class="car-img">
	            	<div class="upload-title"><span class="musthave">*</span>图片上传：<b style="color: red;">点击图片可将其删除,文件类型jpg、png、bmp、jpeg,大小不超过2M</b></div>
	                <div class="layui-upload">
	                    <button type="button" class="layui-btn" id="edit-up-btn">上传图片</button>
	                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
	                    	预览图：
	                        <div class="layui-upload-list" id="pics-wrap"></div>
	                    </blockquote>
	                </div>
	            </div>
			</div>
			<div style="text-align: center;margin:20px auto;">
				<button class="layui-btn" lay-submit lay-filter="submitBtn">发  布</button>
				<button class="layui-btn cancelBtn layui-btn-danger">取消</button>
			</div>
		</form>
	</div>

	<script src="assets/layui/layui.js"></script>
	<script src="assets/js/jquery-2.1.0.js"></script>

	<!--省市地区选择-->
	<script type="text/javascript" src="assets/js/data.js"></script>
	<script type="text/javascript" src="assets/js/province.js"></script>
	<script type="text/javascript">
		var defaults = {
			s1: 'provid',
			s2: 'cityid',
			s3: 'areaid',
			v1: null,
			v2: null,
			v3: null
		};
	</script>
	<!--//省市地区选择-->
	
	<script type="text/javascript" src="assets/js/all.js"></script>
	<script>
		layui.use(["form","element",'layer','upload'],function(){
			var form = layui.form,
				layer = layui.layer,
				upload = layui.upload,
				$ = layui.$

				//多图上传
				upload.render({
		            elem: '#edit-up-btn',
		            url: "", //{:U('Ajax/upload')}
		            multiple: true,
		            size: 1024 * 2,
		            accept:'images',
		            exts:'jpg|png|bmp|jpeg',
		            number: 0,
		            before: function(obj) {
		                layer.msg('图片上传中...', {
		                    icon: 16,
		                    shade: 0.01,
		                    time: 0
		                })
		            },
		            done: function(res) {
		                //上传完毕
		                if(res.code == 0)
		                {
		                    //关闭上传提示窗口
		                    layer.close(layer.msg());
		                    //上传成功预览图片
		                    $('.edit-car-infor #pics-wrap').append('<span><img src="' + res.re_url + '" class="layui-upload-img"><input type="hidden" name="images[]" value="' + res.data_url + '" /></span>');
		                    $(".edit-car-infor").delegate("#pics-wrap span", "click", function() {
		                        var theImg = $(this);
		                        layer.confirm("确定删除此张图片吗？", function(index) {
		                            //移除页面该图片
		                            theImg.remove();
		                            layer.close(index);
		                        })
		                    })
		                } else {
		                    layer.msg(res.msg);
		                }
		            },error:function(index,upload){
		                layer.msg("服务器返回错误！");
		                layer.closeAll('loading');
		
		            }
		        });
			
				//监听发布
		        form.on('submit(submitBtn)', function(data) {
	//	            $.ajax({
	//	                type:"post",
	//	                url:"{:U('/Manager/Accident/add')}",
	//	                data:data.field,
	//	                dataType:"json",
	//	                success:function(res){
	//	                    if(res.code == 0){
	//	                        layer.msg(res.msg,{icon:6,time:1000},function(){
	//	                            window.location.href="carManage.html"
	//	                        });
	//	                    }else{
	//	                        layer.msg(res.msg);
	//	                    }
	//	                },
	//	                error: function(jqXHP,textStatus,errorThrown){
	//	                    layer.alert(jqXHP.responseText);
	//	                }
	//	            });
	//	            return false;
					window.location.href="carManage.html"
		        });
		
		        //保存
		        form.on('submit(saveBtn)', function(data) {
		        	layer.msg("111");
	//	            $.ajax({
	//	                type:"post",
	//	                url:"{:U('/Manager/Ajax/draft')}",
	//	                data:data.field,
	//	                dataType:"json",
	//	                success:function(res){
	//	                    if(res.code == 0){
	//	                        layer.msg(res.msg,{icon:6,time:1000},function(){
	//	                            window.location.href="addCarIndex.html"
	//	                        });
	//	
	//	                    }else{
	//	                        layer.msg(res.msg);
	//	                    }
	//	                },
	//	                error: function(jqXHP,textStatus,errorThrown){
	//	                    layer.alert(jqXHP.responseText);
	//	                }
	//	            });
	//	            return false;
					window.location.href="addCarIndex.html"
		        });
		        $("#department").click(function(){
				var index = layer.open({
					type:2,
					area:['500px','400px'],
					content:'chooseDepart.html',
					btn:["确认"],
					yes:function(idnex,layero){
						var body = layer.getChildFrame('body', index);
		                var iframeWin = window[layero.find('iframe')[0]['name']];//得到iframe页的窗口对象，执行iframe页的方法：
		                var ids = iframeWin.getVal();//调用子页面的方法，得到子页面返回的ids
		                if(ids == undefined){
		                	layer.msg("此层级不可选")
		                }else{
			                $("#department").val(ids);
			                layer.close(index);//需要手动关闭窗口
		                }
					}
				})
			})
		});
	</script>
</body>
</html>
